//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package com.product.system.service.impl;

import cn.hutool.core.lang.tree.Tree;
import cn.hutool.core.lang.tree.TreeNodeConfig;
import cn.hutool.core.lang.tree.TreeUtil;
import com.product.system.domain.ArgpCropGrowthRecords;
import com.product.system.domain.ArgpCrops;
import com.product.system.domain.ArgpQualityInspectionReport;
import com.product.system.domain.ArgpTradesmanCity;
import com.product.system.mapper.ArgpCropsMapper;
import com.product.system.service.ArgpCropsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ArgpCropsServiceImpl implements ArgpCropsService {
    @Autowired
    ArgpCropsMapper argpCropsMapper;




    @Override
    public List<ArgpCrops> list() {
        return argpCropsMapper.list();
    }

    @Override
    public List<ArgpCropGrowthRecords> listgrowth(String DDid) {
        return argpCropsMapper.listgrowth(DDid);
    }

    @Override
    public Boolean add(ArgpCrops argpCrops) {
        return argpCropsMapper.add(argpCrops);
    }

    @Override
    public Boolean listgrowthadd(ArgpCropGrowthRecords argpCropGrowthRecords) {
        return argpCropsMapper.listgrowthadd(argpCropGrowthRecords);
    }

    @Override
    public Boolean update(ArgpCrops argpCrops) {

        return argpCropsMapper.update(argpCrops);
    }

    @Override
    public Boolean listgrowthupdate(ArgpCropGrowthRecords argpCropGrowthRecords) {
        return argpCropsMapper.listgrowthupdate(argpCropGrowthRecords);
    }

    @Override
    public Boolean del(String cropId) {
        return argpCropsMapper.del(cropId);
    }

    @Override
    public List<ArgpTradesmanCity> selectAreas() {
        return null;
    }


    public List<ArgpTradesmanCity> Citylist() {
        return argpCropsMapper.Citylist();
    }

    @Override
    public List<Tree<Object>> selectAllAreas() {
                //配置
        TreeNodeConfig treeNodeConfig = new TreeNodeConfig();
// 自定义属性名 都有默认值的
        treeNodeConfig.setIdKey("id");
        treeNodeConfig.setNameKey("name");
        // 最大递归深度
        treeNodeConfig.setDeep(4);
        treeNodeConfig.setParentIdKey("parentId");
        treeNodeConfig.setChildrenKey("children");
        List<ArgpTradesmanCity>areas= Citylist();

//转换器 (含义:找出父节点为字符串零的所有子节点, 并递归查找对应的子节点, 深度最多为 3)
        List<Tree<Object>> treeNodes = TreeUtil.build(areas, 1, treeNodeConfig,
                (area, tree) -> {
                    tree.setId(area.getId());
                    tree.setParentId(area.getPid());

                    tree.setName(area.getCityName());
                    // 扩展属性 ...
                    tree.putExtra("type",area.getType());
                });



        return treeNodes;


    }

    @Override
    public Boolean Recordadd(ArgpQualityInspectionReport argpQualityInspectionReport) {
        return argpCropsMapper.Recordadd(argpQualityInspectionReport);
    }


}
